<?

/***************************************************************************
Jupiter Content System @ Jupiterportal.org
 
Copyright (C) 2005-2007 Cosmin Flavius (highstrike@gmail.com)
Copyright (C) 2008-2009 George Mark (gmark@jupiterportal.org)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU 
General Public License as published by the Free Software Foundation; either version 3 of the License, 
or (at your option) any later version.

More Info About The License At http://www.gnu.org/copyleft/gpl.html
****************************************************************************/

switch($a)
{
    //-----------------------------------------------------------------
    //  Send Email
    //-----------------------------------------------------------------
    
    case 1:
    
        //-----------------------------------------------------------------
        //  Do Some Checks
        //-----------------------------------------------------------------
        
        $message = NULL;
        
        if ($confirm != $language['Captcha answer'])
        {
            $message = $language['Captcha error'];
        }
        else if (!$email)
        {
            $message = $language['Message desc12'];
        }
        else if (!eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$',
                 $_POST['email']))
        {
            $message = $language['Message desc13'];
        }
        else if (!$_POST['name'])
        {
            $message = $language['Message desc7'];
        }
        else if (!$_POST['subject'])
        {
            $message = $language['Message desc50'];
        }
        else if (!$_POST['message'])
        {
            $message = $language['Message desc51'];
        }
        
        //-----------------------------------------------------------------
		//  Error display
		//-----------------------------------------------------------------

        if ($message)
        {
            $title = $language['Register title_error'];
        }
        else
        {
            //-----------------------------------------------------------------
            //  Strip Tags
            //-----------------------------------------------------------------
            
            $email = jcm_htmlspecialchars(trim(jcm_stripslashes(do_censor($_POST['email']))));		
            $name = jcm_htmlspecialchars(trim(jcm_stripslashes(do_censor($_POST['name']))));		
            $subject = jcm_htmlspecialchars(trim(jcm_stripslashes(do_censor($_POST['subject']))));		
            $message = jcm_htmlspecialchars(trim(jcm_stripslashes(do_censor($_POST['message']))));		
            
            //-----------------------------------------------------------------
            //  Send Email
            //-----------------------------------------------------------------
            
            $recipient = $config['webmaster_email'];
            $header = "From: ". $name . " <" . $email . ">\r\n";
            mail($recipient, $subject, $message, $header);
            
            $title = $language['Contact success_title'];
            $message = $language['Contact success'];
        }
        
        ?>			
        <table class='main' cellspacing='0' cellpadding='4'>
        <tr class='head'>
        <td class='head'><?= $title ?></td>
        <td class='head'align='right'></td>
        </tr>
        <tr><td class="con1" colspan='2'><?= $message ?></td>
        </tr>
        </table>
        <?
        
    //-----------------------------------------------------------------
    //  Redirect User
    //-----------------------------------------------------------------
        
    break;
        
    //-----------------------------------------------------------------
    //  Show Form
    //-----------------------------------------------------------------
    
    default:
    ?>	
        <form method='post' action='<?= $PHP_SELF ?>?n=modules/contactus&a=1'>
        <table class='main' cellpadding='4' cellspacing='1'>
        <col width='30%'><col width='70%'>
        <tr class='head'>
        <td colspan='2'><?= $language['Contact Title'] ?></td>
        </tr>
        <tr class='con1'>
        <td colspan='2'><?= $language['Contact mensaje'] ?></td>
        </tr>
        <tr class='bottom'>
        <td colspan='2'><?= $language['Contact Desc1'] ?></td>
        </tr>
        <tr class='con1'>
        <td><span style='color:green;'><?= $language['Contact Desc2'] ?></span>
        <td><input type='text' id='email' name='email' class='box'
                   style='width: 100%;' onload='focus();' /></td>
        </tr>
        <tr class='con1'>
        <td><span style='color:green;'><?= $language['Contact Desc3'] ?></span>
        <td><input type='text' name='name' class='box' style='width: 100%;' /></td>
        </tr>
        <tr class='bottom'>
        <td colspan='2'><?= $language['Contact Desc4'] ?></td>
        </tr>
        <tr class='con1'>
        <td><span style='color:green;'><?= $language['Contact Desc5'] ?></span>
        <td><input type='text' name='subject' class='box' style='width: 100%;' /></td>
        </tr>
        <tr class='con1'>
        <td valign='top'><span style='color:green;'><?= $language['Contact Desc6'] ?></span></td>
        <td><textarea name='message' rows='5' class='box' style='width: 100%;'></textarea></td>
        </tr>
        <tr class='con1'>
        <td valign='top'><span style='color:green;'>
        <?= $language['Captcha question'] ?></span>
        <td><input name="confirm" type="text" id="confirm" size="8" maxlength="8"
                   class='box'></td>
        </tr>
        <tr class='con1'><td colspan='2' align='right'>
        <input type='submit' name='submit' value='<?= $language['Contact Desc7'] ?>'
               class='box' />
        </td>
        </tr>
        </table>
        </form>
    <?
    
    break;
}
?>
